package pl.edu.pk.mech.kkbus.repository;

import static pl.edu.pk.mech.kkbus.staticstrings.AwardProperty.AWARD_DESCRIPTION;
import static pl.edu.pk.mech.kkbus.staticstrings.AwardProperty.AWARD_NAME;
import static pl.edu.pk.mech.kkbus.staticstrings.AwardProperty.AWARD_POINTS;
import static pl.edu.pk.mech.kkbus.staticstrings.AwardProperty.AWARD_QUANTITY;
import static pl.edu.pk.mech.kkbus.staticstrings.NameEntity.NAME_ENTITY_AWARD;
import static pl.edu.pk.mech.kkbus.staticstrings.NameEntity.NAME_ENTITY_USERS;
import static pl.edu.pk.mech.kkbus.staticstrings.UserProperty.USER_EMAIL;

import java.util.ArrayList;
import java.util.List;

import pl.edu.pk.mech.kkbus.datastore.common.SynchronizeCommon;
import pl.edu.pk.mech.kkbus.model.Award;
import pl.edu.pk.mech.kkbus.model.Pojo;
import pl.edu.pk.mech.kkbus.model.User;

import com.google.appengine.api.datastore.Entity;

public class AwardDAO extends BaseDAO{	
	
	  public List<Award> getAllAward() {
		  List<Award> temp = new ArrayList<Award>();
		  Iterable<Entity> entityList = SynchronizeCommon.listEntities(NAME_ENTITY_AWARD, null, null);
		  for (Entity entity : entityList) {
			  temp.add(new Award(entity));
		  }
		  return temp;
	  }
	  
	  public Award getAward(long id){
		  	  Entity entityTemp = getEntity(id, NAME_ENTITY_AWARD);
		  	  if (entityTemp != null) {
		  		  return new Award(entityTemp);
		  	  }
			  return null;
		}

	@Override
	public void fillProperty(Pojo pojo, Entity entity) {
		  Award award = (Award) pojo;
		  entity.setProperty(AWARD_NAME, award.getName());
		  entity.setProperty(AWARD_DESCRIPTION, award.getDescription());
		  entity.setProperty(AWARD_POINTS, award.getPoints());
		  entity.setProperty(AWARD_QUANTITY, award.getQuantity());
	}
}










